<?php
class Model_Contact extends System_App_Model_Abstract{
	protected $table = 'contact';
	
	public static $structure = array(
		'id'=>array( 'type'=>'int', 'editable'=>'hidden' )
		,'societe'=>array( 'type'=>'string', 'editable'=>'none', 'label' => 'societe' )
		,'societe_id'=>array( 'type'=>'int', 'editable'=>'hidden', 'label' => 'societe' )
		,'nom'=>array( 'type'=>'string', 'editable'=>'input', 'max' => 255 )
		,'prenom'=>array( 'type'=>'string', 'editable'=>'input', 'max' => 255 )
		,'genre'=>array( 'type'=>'string', 'editable'=>'select', 'values' => array( 'mr'=>'monsieur', 'mme'=>'madame', 'mlle'=>'mademoiselle' ) )
		,'email1'=>array( 'type'=>'mail', 'editable'=>'input', 'max' => 512 )
		,'email2'=>array( 'type'=>'mail', 'editable'=>'input', 'max' => 512 )
		,'telephone1'=>array( 'type'=>'phone', 'editable'=>'input', 'max' => 20 )
		,'telephone2'=>array( 'type'=>'phone', 'editable'=>'input', 'max' => 20 )
		,'notes'=>array( 'type'=>'string', 'editable'=>'textarea')
		,'date_crea'=>array( 'type'=>'datetime', 'editable'=>'none', 'label'=>'d&acirc;te de cr&eacute;ation')
		,'date_edit'=>array( 'type'=>'datetime', 'editable'=>'none', 'label'=>'derni&egrave;re &eacute;dition')
	);
	
	private $_id;
	private $_societe_id;
	private $_nom;
	private $_prenom;
	private $_genre;
	private $_email1;
	private $_email2;
	private $_fonction;
	private $_telephone1;
	private $_telephone2;
	private $_notes;
	private $_date_crea;
	private $_date_edit;
	
	public function toArray(){
		return array(
			'id'=>$this->getId()
			,'societe_id'=>$this->getSocieteId()
			,'nom'=>$this->getNom()
			,'prenom'=>$this->getPrenom()
			,'genre'=>$this->getGenre()
			,'email1'=>$this->getEmail1()
			,'email2'=>$this->getEmail2()
			,'fonction'=>$this->getFonction()
			,'telephone1'=>$this->getTelephone1()
			,'telephone2'=>$this->getTelephone2()
			,'notes'=>$this->getnotes()
			,'date_crea'=>$this->getDateCrea()
			,'date_edit'=>$this->getDateEdit()
		);
	}
	
	/* getter */
	public function getId(){
		return $this->_id;
	}
	public function getSocieteId(){
		return $this->_societe_id;
	}
	public function getSociete(){
		return new Model_Societe( $this->_societe_id );
	}
	public function getNom(){
		return $this->_nom;
	}
	public function getPrenom(){
		return $this->_prenom;
	}
	public function getGenre(){
		return $this->_genre;
	}
	public function getEmail1(){
		return $this->_email1;
	}
	public function getEmail2(){
		return $this->_email2;
	}
	public function getTelephone1(){
		return $this->_telephone1;
	}
	public function getTelephone2(){
		return $this->_telephone2;
	}
	public function getFonction(){
		return $this->_fonction;
	}
	public function getNotes(){
		return $this->_notes;
	}
	public function getDateCrea(){
		return $this->_date_crea;
	}
	public function getDateEdit(){
		return $this->_date_edit;
	}
	
	/* setter */
	public function setId( $value ){
		$this->_id = $value;
	}
	public function setSociete( $value ){
		if( is_int($value) )$this->_societe_id = $value;
		else $this->_societe_id = $value->getId();
	}
	public function setSocieteId( $value ){
		$this->_societe_id = $value;
	}
	public function setNom( $value ){
		$this->_nom = $value;
	}
	public function setPrenom( $value ){
		$this->_prenom = $value;
	}
	public function setGenre( $value ){
		$this->_genre = $value;
	}
	public function setEmail1( $value ){
		$this->_email1 = $value;
	}
	public function setEmail2( $value ){
		$this->_email2 = $value;
	}
	public function setTelephone1( $value ){
		$this->_telephone1 = $value;
	}
	public function setTelephone2( $value ){
		$this->_telephone2 = $value;
	}
	public function setFonction( $value ){
		$this->_fonction = $value;
	}
	public function setNotes( $value ){
		$this->_notes = $value;
	}
	public function setDateCrea( $value ){
		$this->_date_crea = $value;
	}
	public function setDateEdit( $value ){
		$this->_date_edit = $value;
	}
}
?>